package com.children.growth.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.children.growth.entity.MentalHealth;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 心理健康 Mapper 接口
 * 
 * @author children
 * @since 1.0.0
 */
@Mapper
public interface MentalHealthMapper extends BaseMapper<MentalHealth> {
    
    /**
     * 查询用户平均情绪分数
     * 
     * @param userId 用户ID
     * @return 平均情绪分数
     */
    @Select("SELECT AVG(emotion_score) FROM mental_health WHERE user_id = #{userId} AND deleted = 0")
    Double selectAvgEmotionScore(@Param("userId") Long userId);
    
    /**
     * 查询用户平均行为分数
     * 
     * @param userId 用户ID
     * @return 平均行为分数
     */
    @Select("SELECT AVG(behavior_score) FROM mental_health WHERE user_id = #{userId} AND deleted = 0")
    Double selectAvgBehaviorScore(@Param("userId") Long userId);
    
    /**
     * 查询用户平均社交分数
     * 
     * @param userId 用户ID
     * @return 平均社交分数
     */
    @Select("SELECT AVG(social_score) FROM mental_health WHERE user_id = #{userId} AND deleted = 0")
    Double selectAvgSocialScore(@Param("userId") Long userId);
    
    /**
     * 查询用户平均学习分数
     * 
     * @param userId 用户ID
     * @return 平均学习分数
     */
    @Select("SELECT AVG(learning_score) FROM mental_health WHERE user_id = #{userId} AND deleted = 0")
    Double selectAvgLearningScore(@Param("userId") Long userId);
    
    /**
     * 查询用户平均综合分数
     * 
     * @param userId 用户ID
     * @return 平均综合分数
     */
    @Select("SELECT AVG(overall_score) FROM mental_health WHERE user_id = #{userId} AND deleted = 0")
    Double selectAvgOverallScore(@Param("userId") Long userId);
} 